package o;

import android.content.Context;
import com.huawei.appgallery.serverreqkit.api.bean.startup.StartupResponse.OOBEAppInfo;
import com.huawei.appgallery.serverreqkit.api.bean.startup.StartupResponse.OOBEInfos;
import com.huawei.appmarket.service.apppermission.bean.DownloadPermissionResponse.AppPermissionInfo;
import java.util.ArrayList;
import java.util.List;

public class dld {
    private static boolean ˋ = false;
    private static final dld ˏ = new dld();
    private List<OOBEAppInfo> ʻ = new ArrayList();
    private List<OOBEAppInfo> ʼ = new ArrayList();
    private boolean ʽ = false;
    private List<OOBEAppInfo> ˊ = new ArrayList();
    private List<AppPermissionInfo> ˊॱ = new ArrayList();
    private String ˋॱ = null;
    private List<OOBEAppInfo> ˎ = new ArrayList();
    private boolean ˏॱ = false;
    private int ͺ = 0;
    private List<OOBEAppInfo> ॱ = new ArrayList();
    private int ॱˊ = 0;
    private boolean ॱˎ = false;
    private List<OOBEAppInfo> ॱॱ = new ArrayList();
    private boolean ॱᐝ = false;
    private List<OOBEAppInfo> ᐝ = new ArrayList();
    private int ᐝॱ = 4;

    private dld() {
    }

    public static dld ˎ() {
        return ˏ;
    }

    public static List<OOBEAppInfo> ˊ(Context context, List<OOBEAppInfo> list) {
        List<OOBEAppInfo> arrayList = new ArrayList();
        if (!(list == null || list.isEmpty())) {
            for (OOBEAppInfo oOBEAppInfo : list) {
                List<OOBEAppInfo> ॱˊ = oOBEAppInfo.ॱˊ();
                if (ॱˊ != null && ॱˊ.size() > 0) {
                    for (OOBEAppInfo oOBEAppInfo2 : ॱˊ) {
                        if (!dli.ˊ(context, oOBEAppInfo2.ˎ())) {
                            ˏ(arrayList, oOBEAppInfo2);
                        }
                    }
                }
                if (!dli.ˊ(context, oOBEAppInfo.ˎ())) {
                    ˏ(arrayList, oOBEAppInfo);
                }
            }
            for (OOBEAppInfo oOBEAppInfo3 : ˎ().ʽ()) {
                if (!dli.ˊ(context, oOBEAppInfo3.ˎ())) {
                    ˏ(arrayList, oOBEAppInfo3);
                }
            }
        }
        return arrayList;
    }

    private static void ˏ(List<OOBEAppInfo> list, OOBEAppInfo oOBEAppInfo) {
        Object obj;
        for (OOBEAppInfo oOBEAppInfo2 : list) {
            if (oOBEAppInfo2.ˎ() != null && oOBEAppInfo2.ˎ().equals(oOBEAppInfo.ˎ())) {
                obj = 1;
                break;
            }
        }
        obj = null;
        if (obj == null) {
            list.add(oOBEAppInfo);
        }
    }

    public static void ˋ(boolean z) {
        ˋ = z;
    }

    public static void ˊ() {
        if (!ˋ) {
            dkz ॱ = dkz.ॱ();
            if (ॱ != null) {
                ˎ().ˏ(ॱ.ˏ());
                ˎ().ˎ(ॱ.ˊ());
                OOBEInfos ˋ = ॱ.ˋ();
                if (ˋ != null) {
                    ˎ().ॱˎ();
                    ˎ().ˎ(ˋ.ˎ());
                    if (ˋ.ˏ() != null) {
                        ˎ().ʻॱ().addAll(ˋ.ˏ());
                    }
                    if (ˋ.ˋ() != null) {
                        ˎ().ʽ().addAll(ˋ.ˋ());
                    }
                    ˎ().ॱ(ContentManager.getInstant().getContext());
                }
                ˋ = true;
            }
        }
    }

    public List<OOBEAppInfo> ˏ() {
        return this.ʻ;
    }

    public List<AppPermissionInfo> ॱ() {
        return this.ˊॱ;
    }

    public List<OOBEAppInfo> ˋ() {
        return this.ॱ;
    }

    public List<OOBEAppInfo> ᐝ() {
        return this.ˎ;
    }

    public List<OOBEAppInfo> ʼ() {
        return this.ᐝ;
    }

    public boolean ॱॱ() {
        return this.ʽ;
    }

    public void ˎ(boolean z) {
        this.ʽ = z;
    }

    public boolean ʻ() {
        return this.ˏॱ;
    }

    public void ˏ(boolean z) {
        this.ˏॱ = z;
    }

    public List<OOBEAppInfo> ʽ() {
        return this.ॱॱ;
    }

    public List<OOBEAppInfo> ͺ() {
        return this.ʼ;
    }

    public int ˊॱ() {
        return this.ॱˊ;
    }

    public void ˋ(int i) {
        this.ॱˊ = i;
    }

    public int ˋॱ() {
        return this.ͺ;
    }

    public void ˎ(int i) {
        this.ͺ = i;
    }

    public String ॱˊ() {
        return this.ˋॱ;
    }

    public void ˏ(String str) {
        this.ˋॱ = str;
    }

    public int ˏॱ() {
        return this.ᐝॱ;
    }

    public void ॱ(int i) {
        this.ᐝॱ = i;
    }

    public List<OOBEAppInfo> ʻॱ() {
        return this.ˊ;
    }

    public boolean ॱᐝ() {
        return this.ॱˎ;
    }

    public void ˊ(boolean z) {
        this.ॱˎ = z;
    }

    public String ॱˋ() {
        return eqp.ॱ();
    }

    public void ˎ(Context context) {
        if (ˎ().ᐝ().isEmpty()) {
            ˊ();
            if (ˎ().ʼ().isEmpty()) {
                Logger.ˎ("OOBE", "no default apps");
                return;
            }
            ˎ().ᐝ().addAll(ˎ().ʼ());
            ˎ().ͺ().clear();
            ˎ().ͺ().addAll(ˊ(context, ˎ().ᐝ()));
            dli.ˏ("350210", dli.ʽ(context));
            return;
        }
        ˎ().ͺ().clear();
        ˎ().ͺ().addAll(ˊ(context, ˎ().ᐝ()));
    }

    public void ॱ(Context context) {
        List<OOBEAppInfo> ʻॱ = ˎ().ʻॱ();
        ˎ().ʼ().clear();
        int ˋॱ = dli.ˋॱ(context);
        int i = 0;
        for (OOBEAppInfo oOBEAppInfo : ʻॱ) {
            if (!dli.ˊ(context, oOBEAppInfo.ˎ())) {
                ˎ().ˋ().add(oOBEAppInfo);
                if (oOBEAppInfo.ˏॱ() == 2 || oOBEAppInfo.ˏॱ() == 3) {
                    ˎ().ʼ().add(oOBEAppInfo);
                }
                int i2 = i + 1;
                if (i2 >= ˋॱ) {
                    break;
                }
                i = i2;
            }
        }
        ˈ();
    }

    private void ˈ() {
        int size = this.ͺ - this.ᐝ.size();
        if (size > 0) {
            int i = size;
            for (OOBEAppInfo oOBEAppInfo : ˎ().ˋ()) {
                if (this.ᐝ.contains(oOBEAppInfo)) {
                    size = i;
                } else {
                    this.ᐝ.add(oOBEAppInfo);
                    size = i - 1;
                    if (size <= 0) {
                        return;
                    }
                }
                i = size;
            }
        }
    }

    public void ॱˎ() {
        if (this.ˎ != null) {
            this.ˎ.clear();
        }
        if (this.ॱ != null) {
            this.ॱ.clear();
        }
        if (this.ᐝ != null) {
            this.ᐝ.clear();
        }
        if (this.ʼ != null) {
            this.ʼ.clear();
        }
        if (this.ˊ != null) {
            this.ˊ.clear();
        }
    }

    public boolean ᐝॱ() {
        return dli.ˊ(ContentManager.getInstant().getContext()).getBoolean("isSupport", false);
    }

    public void ॱ(boolean z) {
        Context ˋ = ContentManager.getInstant().getContext();
        dli.ˊ(ˋ).edit().putBoolean("isSupport", z).commit();
        if (dli.ˏ(ˋ) && ˎ().ॱᐝ()) {
            ˎ().ˊ(false);
        }
    }

    public int ʼॱ() {
        return dli.ˊ(ContentManager.getInstant().getContext()).getInt("policy", 0);
    }

    public int ʾ() {
        return dli.ˊ(ContentManager.getInstant().getContext()).getInt("policyShowed", 0);
    }

    public void ˏ(int i) {
        dli.ˊ(ContentManager.getInstant().getContext()).edit().putInt("policyShowed", i).commit();
    }

    public String ʿ() {
        return dli.ˊ(ContentManager.getInstant().getContext()).getString("VNKey", "");
    }

    public void ˎ(String str) {
        dli.ˊ(ContentManager.getInstant().getContext()).edit().putString("VNKey", str).commit();
    }

    public boolean ʽॱ() {
        return this.ॱᐝ;
    }

    public void ʻ(boolean z) {
        this.ॱᐝ = z;
    }
}
